﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Extensions
{
   public static class CoreExtensions
    {
       /// <summary>
       /// 
       /// </summary>
       /// <typeparam name="T"></typeparam>
       /// <param name="value"></param>
       /// <returns></returns>
       public static T ConvertTo<T>(this IConvertible value)
       {
           return (T)Convert.ChangeType(value, typeof(T));
       }


       /// <summary>
       /// 
       /// </summary>
       /// <typeparam name="T"></typeparam>
       /// <param name="value"></param>
       /// <param name="low"></param>
       /// <param name="high"></param>
       /// <returns></returns>
       public static bool IsBetween<T>(this T value, T low, T high) where T : IComparable<T>
       {
           return value.CompareTo(low) >= 0 && value.CompareTo(high) <= 0;
       }
    }
}
